package org.ihelpuoo.orm.handler;

import java.lang.reflect.Field;
import java.lang.reflect.Method;
import java.util.List;

import org.ihelpuoo.lang.ObjectUtils;
import org.ihelpuoo.orm.ObjectRule;
import org.ihelpuoo.orm.filter.FieldFilter;
import org.ihelpuoo.orm.filter.Filter;

public abstract class ReadListFieldHandler extends ReadCollectionFieldHandler
{

	public ReadListFieldHandler(ObjectProcessor beanHandler)
	{
		super(beanHandler);
	}

	@Override
	protected void processWithoutExceptionHandle(ObjectRule r, Field f, Object src, Object obj,
			FieldFilter actived, FieldFilter locked, String prefix) throws Exception
	{
		Class subType = r.getComponentType(f);
		Filter filter = evalBeanFilter(r,f,obj);

		List list = evalSubList(r,f,src,filter,obj,subType);
		Method setter = ObjectUtils.getSetter(obj.getClass(),f);
		setter.invoke(obj,new Object[]{list});
	}
}
